# encoding=utf-8

import time, threading
import config, instruction, utils
from bot2 import Bot

lock = threading.Lock()

total  = 100
current = 0
def prepare(bot):
    pass
    
def emptytask(bot):
    global lock, total, current
    lock.acquire()
    current += 1
    lock.release()

def main():
    for i in range(100, 200):
        username = 'minerbott' + str(i)
        bot = Bot(username, '123456')

        bot.set_register_addr(config.regsi_server)
        bot.set_login_addr(config.login_server)    

        bot.set_prepare(prepare)
        bot.set_task(emptytask, 1, 1)
        
        bot.start()
    
    # waiting all thread

    global lock, total, current
    while True:
        lock.acquire()
        print '%d/%d' % (current, total)
        if current == total:
            lock.release()
            break
        lock.release()
        time.sleep(0.1)

    print '[*] All bot has accomplish!!!!'

main()